<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<div id="log"></div>
<script>
test(() => assert_selection(
    [
        '<div contenteditable>',
            '<div>foo</div><div>^bar</div>|<div>baz</div>',
        '</div>',
    ].join(''),
    'insertParagraph',
    [
        '<div contenteditable>',
            '<div>foo</div><div><br></div><div>|baz</div>',
        '</div>',
    ].join('')),
    'insertParagraph until end of DIV');

test(() => assert_selection(
    [
        '<div contenteditable>',
            '<div>foo</div><div>^bar</div><div>|baz</div>',
        '</div>',
    ].join(''),
    'insertParagraph',
    [
        '<div contenteditable>',
            '<div>foo</div><div><br></div><div>|baz</div>',
        '</div>',
    ].join('')),
    'insertParagraph until start of following DIV');

test(() => assert_selection(
    [
        '<div contenteditable>',
            '<div>foo</div><div>^bar</div><div id="baz">b|baz</div>',
        '</div>',
    ].join(''),
    'insertParagraph',
    [
        '<div contenteditable>',
            // "div[id="baz"] has been gone.
            '<div>foo</div><div><br></div><div>|baz</div>',
        '</div>',
    ].join('')),
    'insertParagraph crossing end of DIV');

test(() => assert_selection(
    [
        '<div contenteditable>',
            '<div>foo</div><div>^bar|</div><div>baz</div>',
        '</div>',
    ].join(''),
    'insertParagraph',
    [
        '<div contenteditable>',
            '<div>foo</div><div><br></div><div>|<br></div><div>baz</div>',
        '</div>',
    ].join('')),
    'insertParagraph on fully selected line');
</script>
